/** @file cardtest4.c
*   @brief Test treasure_map()
*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <assert.h>
#include <stdio.h>
#include <limits.h>

int main(int argc, char **argv)
{
    // Treasure map effects: Trash 2 copies of treasure map. gain 4 golds
    // If only one copy, trash it, gain nothing

    printf("Running tests for Treasure Map card.\n");


    int nPlayers = 2;
    int k[]      = {adventurer,
                    council_room,
                    feast,
                    gardens,
                    mine,
                    remodel,
                    smithy,
                    village,
                    baron,
                    great_hall
                   };
    int seed = 2;
    struct gameState g1;

    initializeGame(nPlayers, k, seed, &g1);



    int player  = 0;
    int card    = treasure_map;
    int choice1 = 0;
    int choice2 = 0;
    int choice3 = 0;
    int handPos = 0;
    int bonus   = 0;

    // ensure that top 4 cards of deck are not gold
    g1.deck[player][g1.deckCount[player] - 1] = copper;
    g1.deck[player][g1.deckCount[player] - 2] = copper;
    g1.deck[player][g1.deckCount[player] - 3] = copper;
    g1.deck[player][g1.deckCount[player] - 4] = copper;

    // two treasure map copies in hand
    g1.handCount[player] = 5;
    g1.hand[player][0] = treasure_map;
    g1.hand[player][1] = smithy;
    g1.hand[player][2] = treasure_map;
    g1.hand[player][3] = silver;
    g1.hand[player][4] = gold;
    cardEffect(card, choice1, choice2, choice3, &g1, handPos, &bonus);
    assert(g1.deck[player][g1.deckCount[player] - 1] == gold);
    assert(g1.deck[player][g1.deckCount[player] - 2] == gold);
    assert(g1.deck[player][g1.deckCount[player] - 3] == gold);
    assert(g1.deck[player][g1.deckCount[player] - 4] == gold);


    // ensure that top 4 cards of deck are not gold
    g1.deck[player][g1.deckCount[player] - 1] = copper;
    g1.deck[player][g1.deckCount[player] - 2] = copper;
    g1.deck[player][g1.deckCount[player] - 3] = copper;
    g1.deck[player][g1.deckCount[player] - 4] = copper;

    // only one treasure map copies in hand
    g1.handCount[player] = 5;
    g1.hand[player][0] = treasure_map;
    g1.hand[player][1] = smithy;
    g1.hand[player][2] = silver;
    g1.hand[player][3] = silver;
    g1.hand[player][4] = gold;
    cardEffect(card, choice1, choice2, choice3, &g1, handPos, &bonus);
    assert(g1.deck[player][g1.deckCount[player] - 1] != gold);
    assert(g1.deck[player][g1.deckCount[player] - 2] != gold);
    assert(g1.deck[player][g1.deckCount[player] - 3] != gold);
    assert(g1.deck[player][g1.deckCount[player] - 4] != gold);


    printf("Tests passed for treasure_map card.\n");

}
